﻿<!DOCTYPE html>
<html>
<head>
<!--
	Copyright (c) 2015-2018 Jean-Marc VIGLINO,
	released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
-->
	<title>ol-ext: Placemark overlay</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

	<meta name="description" content="styled popup for OL3" />
	<meta name="keywords" content="ol3, popup, overlay, placemark, jQuery, style" />

	<!-- jQuery -->
	<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
  
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  
	<!-- Openlayers -->
  <link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" />
	<script type="text/javascript" src="https://openlayers.org/en/latest/build/ol.js"></script>
  <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL,Object.assign"></script>
	
	<!-- ol-ext -->
    <link rel="stylesheet" href="../../dist/ol-ext.css" />
	<script type="text/javascript" src="../../dist/ol-ext.js"></script>

  <link rel="stylesheet" href="../style.css" />

  <style>
    .placemark .ol-popup-content * {
      color: inherit!important;
    }
    button i {
      color: #000;
    }
  </style>

</head>
<body >
  <a href="https://github.com/Viglino/ol-ext" class="icss-github-corner"><i></i></a>
  
	<a href="../../index.html">
		<h1>ol-ext: Placemark overlay</h1>
	</a>

	<div class="info">
    <p>
      <i>ol/Overlay/Placemark</i> is an easy way to display a placemark on the map. 
      <br/>
      A placemark is an <a href="map.popup.anim.html">ol/Overlay/Popup</a> with custom CSS.
    </p>
		<ul>
			<li>
        choose the placemark class and use the anim class to add a bounce animation
      </li>
      <li>
        set the placemark <i>size</i> in your CSS or as a parameter
      </li>
			<li>
        you can change the <i>color</i> and <i>backgroundcolor</i> of the placemarck.
      </li>
    </ul>
		<p>
      <i>ol.Overlay.Popup</i> necessite jQuery.
    </p>
	</div>

	<!-- DIV pour la carte -->
	<div id="map" style="width:600px; height:400px;"></div>

	<div class="options">
    <ul>
      <li>
        <label>Class:</label>
        <select onchange="placemark.setClassName(this.value);">
          <option value=''>default</option>
          <option value='pushpin'>pushpin</option>
          <option value='needle'>needle</option>
          <option value='shield'>shield</option>
          <option value='blazon'>blazon</option>
          <option value='flag'>flag</option>
          <option value='flagv'>flagv</option>
          <option value='flag finish'>finish</option>
        </select>
      </li>
      <li>
        Size:
        <select onchange="placemark.setRadius(Number(this.value)); placemark.show(placemark.getPosition())">
          <option value='15'>default</option>
          <option value='20'>big</option>
          <option value='10'>small</option>
        </select>
      </li>
      <li>
        Color:
        <select onchange="placemark.setColor(this.value);">
          <option value='#c00'>red</option>
          <option value='#080'>green</option>
          <option value='#00c'>blue</option>
        </select>
      </li>
      <li>
        Background color:
        <select onchange="placemark.setBackgroundColor(this.value);">
          <option value='transparent'>tranparent</option>
          <option value='#fff'>white</option>
          <option value='#f00'>red</option>
          <option value='#0f0'>green</option>
          <option value='#00f'>blue</option>
        </select>
      </li>
      <li>
        Content:
        <button onclick='placemark.show(placemark.getPosition()," ");'>none</button>
        <button onclick='placemark.show(placemark.getPosition(),"1");'>1</button>
        <button onclick='placemark.show(placemark.getPosition(),"2");'>2</button>
        <button onclick='placemark.show(placemark.getPosition(),"<i class=\"fa fa-user\"></i>");'><i class="fa fa-user"></i></button>
        <button onclick='placemark.show(placemark.getPosition(),"<i class=\"fa fa-bus\"></i>");'><i class="fa fa-bus"></i></button>
        <button onclick='placemark.show(placemark.getPosition(),"<i class=\"fa fa-cutlery\"></i>");'><i class="fa fa-cutlery"></i></button>
        <button onclick='placemark.show(placemark.getPosition(),"<i class=\"fa fa-github-alt\"></i>");'><i class="fa fa-github-alt"></i></button>
        <button onclick='placemark.show(placemark.getPosition(),"<i class=\"fa fa-home\"></i>");'><i class="fa fa-home"></i></button>
        <button onclick='placemark.show(placemark.getPosition(),"<i class=\"fa fa-h-square\"></i>");'><i class="fa fa-h-square"></i></button>
      </li>
      <li>
        Content color:
        <select onchange="placemark.setContentColor(this.value);">
            <option value='#000'>black</option>
            <option value='#fff'>white</option>
        </select>
      </li>
    </ul>
	</div>
	<p>Click on the map to show a popup !</p>
	
	<script type="text/javascript">
  // Layers
  var layers = [
    new ol.layer.Tile({
			title:'terrain-background',
			source: new ol.source.Stamen({ layer: 'terrain' })
		})
  ];

	// Popup overlay
	var placemark = new ol.Overlay.Placemark ({
    // color: '#369',
    // backgroundColor : 'yellow',
    contentColor: '#000',
    onshow: function(){ console.log("You opened a placemark"); },
    autoPan: true,
    autoPanAnimation: { duration: 250 }
  });
		
	// The map
	var map = new ol.Map ({
    target: 'map',
    view: new ol.View ({
      zoom: 5,
      center: [166326, 5992663]
    }),
    layers: layers,
    overlays: [placemark]
  });

	// On click => show popup
	map.on('click', function(e) {
		placemark.show(e.coordinate); 
  });

	</script>
	
</body>
</html>